package com.party.core.service.photo.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.photo.PhotosMemberOperateDetailReadDao;
import com.party.core.dao.write.photo.PhotosMemberOperateDetailWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.photo.PhotosMemberOperateDetail;
import com.party.core.service.photo.IPhotosMemberOperateDetailService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @Description:
 * @Author: yangshoukun
 * @Date: 2018/5/30 14:28
 */
@Service
public class PhotosMemberOperateDetailService implements IPhotosMemberOperateDetailService {

    @Autowired
    private PhotosMemberOperateDetailReadDao photosMemberOperateDetailReadDao;

    @Autowired
    private PhotosMemberOperateDetailWriteDao photosMemberOperateDetailWriteDao;

    @Override
    public String insert(PhotosMemberOperateDetail photosMemberOperateDetail) {
        BaseModel.preInsert(photosMemberOperateDetail);
        boolean result = photosMemberOperateDetailWriteDao.insert(photosMemberOperateDetail);
        if (result){
            return photosMemberOperateDetail.getId();
        }
        return null;
    }

    @Override
    public boolean update(PhotosMemberOperateDetail photosMemberOperateDetail) {
        return photosMemberOperateDetailWriteDao.update(photosMemberOperateDetail);
    }

    @Override
    public boolean deleteLogic(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return photosMemberOperateDetailWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return photosMemberOperateDetailWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return false;
        }
        return photosMemberOperateDetailWriteDao.batchDeleteLogic(ids);
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return false;
        }
        return photosMemberOperateDetailWriteDao.batchDelete(ids);
    }

    @Override
    public PhotosMemberOperateDetail get(String id) {
        return photosMemberOperateDetailReadDao.get(id);
    }

    @Override
    public List<PhotosMemberOperateDetail> listPage(PhotosMemberOperateDetail photosMemberOperateDetail, Page page) {
        return photosMemberOperateDetailReadDao.listPage(photosMemberOperateDetail, page);
    }

    @Override
    public List<PhotosMemberOperateDetail> list(PhotosMemberOperateDetail photosMemberOperateDetail) {
        return listPage(photosMemberOperateDetail, null);
    }

    @Override
    public List<PhotosMemberOperateDetail> batchList(Set<String> ids, PhotosMemberOperateDetail photosMemberOperateDetail, Page page) {
        return null;
    }

    @Override
    public PhotosMemberOperateDetail getLastTimeOperate(PhotosMemberOperateDetail detail) {
        return photosMemberOperateDetailReadDao.getLastTimeOperate(detail);
    }

    @Override
    public void deleteByPhotoId(String photoId) {
        photosMemberOperateDetailWriteDao.deleteByPhotoId(photoId);
    }

    @Override
    public List<String> hasOperatedImg() {
        return photosMemberOperateDetailReadDao.hasOperatedImg();
    }
}
